home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0152_Gravity.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  1KB  |  41 lines

  1. {
  2.  JM> ex. pixel in screen is x = 160, y = 100 and ground level = 190.
  3.  JM> Then that pixel has to drop down like a gravity affect to
  4.  JM> pixel.. then it would look that there were an gravity..
  5.  
  6. >--- cut here
  7. }
  8. program cannonball;
  9. uses crt;
  10. const vidseg:word=$a000; g=-9.81; x0=0; y0=100; v0=50; phi=50; dt=0.1;
  11. var t:real; px,py,xt,yt,v:integer;
  12.  
  13. procedure retrace; assembler; asm
  14.   mov dx,03dah; @vert1: in al,dx; test al,8; jnz @vert1
  15.   @vert2: in al,dx; test al,8; jz @vert2; end;
  16.  
  17. function rad(alpha:integer):real; begin
  18.   rad:=(alpha/180)*pi; end;
  19.  
  20. begin
  21.   asm mov ax,13h; int 10h; end;
  22.   px:=0; py:=0;
  23.   t:=0; v:=v0; yt:=1;
  24.   while (not keypressed) and (yt>=0) do begin
  25.     retrace;
  26.     mem[vidseg:(199-py)*320+px]:=0;
  27.     xt:=x0+round(v0*cos(rad(phi))*t);
  28.     yt:=y0+round(v*sin(rad(phi))*t+0.5*g*t*t);
  29.     mem[vidseg:(199-yt)*320+xt]:=15;
  30.     px:=xt; py:=yt;
  31.     t:=t+dt;
  32.   end;
  33.   while keypressed do readkey;
  34.   while not keypressed do;
  35.   textmode(lastmode);
  36. end.
  37.  
  38. >--- cut here
  39.  
  40. This is the only correct physical approuch (I should know, I study Physics).
  41.